/*    */ package com.zimbra.cs.db;
/*    */ 
/*    */ import java.sql.Connection;
/*    */ import java.sql.SQLException;
/*    */ import java.util.Properties;
/*    */ import org.apache.commons.dbcp.DriverManagerConnectionFactory;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class RetryConnectionFactory
/*    */   extends DriverManagerConnectionFactory
/*    */ {
/*    */   public RetryConnectionFactory(String connectUri, Properties props)
/*    */   {
/* 32 */     super(connectUri, props);
/*    */   }
/*    */   
/*    */   public Connection createConnection() throws SQLException
/*    */   {
/* 37 */     AbstractRetry<Connection> exec = new AbstractRetry()
/*    */     {
/*    */       public ExecuteResult<Connection> execute() throws SQLException {
/* 40 */         Connection conn = RetryConnectionFactory.this.superCreateConnection();
/* 41 */         Db.getInstance().postCreate(conn);
/* 42 */         return new ExecuteResult(new RetryConnection(conn));
/*    */       }
/*    */       
/*    */       protected boolean retryException(SQLException sqle)
/*    */       {
/* 47 */         return (super.retryException(sqle)) || (Db.errorMatches(sqle, Db.Error.CANTOPEN));
/*    */       }
/*    */       
/* 50 */     };
/* 51 */     return (Connection)exec.doRetry().getResult();
/*    */   }
/*    */   
/*    */   private Connection superCreateConnection() throws SQLException {
/* 55 */     return super.createConnection();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/db/RetryConnectionFactory.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */